******************************************************************
****************************************************************** Replication material for 
****************************************************************** "Initiator conditions and the diffusion of digital trade-related provisions in PTAs"
****************************************************************** Manfred Elsig and Sebastian Klotz
****************************************************************** 


*** Set working directory. Please adjust accordingly.


clear
set more off
cd "XXXXX"


*** Import data


clear
use online_appendix_elsig_klotz_2021_data


*** Replicate "Table 1: Provision labels and description"


* As indicated in the manuscript, this table is manually extracted from Burri and Polanco (2020).


*** Replicate "Table 2: Summary statistics"


clear
use online_appendix_elsig_klotz_2021_data
outreg2 using "XXXXX\Table_2.doc", replace sum(log) keep(total_diffusion power_diffusion non_power_diffusion countries_diffusion GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data IPR Year) 


*** Replicate "Table 3: Correlation matrix"


clear
use online_appendix_elsig_klotz_2021_data
correlate ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Legalization GDP Polity No_of_members GDP_asymmetry Intercontinental USA_member Ecommerce Data IPR Year


*** Replicate "Table 4: Provisions, PTAs, and initiators"


clear
use online_appendix_elsig_klotz_2021_data
gen sortvar = total_diffusion*-1
sort sortvar Year
keep provision_name provision_first_pta provision_first_power_alpha


*** Replicate "Table 5: Empirical results"


clear
use online_appendix_elsig_klotz_2021_data
nbreg total_diffusion GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data IPR Year, vce(robust)
margins, dydx(*) post
estimates store total_diffusion_nbreg
outreg2 [total_diffusion_nbreg] using  "XXXXX\Table_5.doc", replace keep(GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data Year) addtext(Model, Negative binominal) ctitle(Total diffusion) nonotes addnote(Robust standard errors in parentheses., *** p<0.01; ** p<0.05; * p<0.1)


nbreg countries_diffusion GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data IPR Year, vce(robust)
margins, dydx(*) post
estimates store countries_diffusion_nbreg
outreg2 [countries_diffusion_nbreg] using  "XXXXX\Table_5.doc", append keep(GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data Year) addtext(Model, Negative binominal) ctitle(External diffusion) nonotes addnote(Robust standard errors in parentheses., *** p<0.01; ** p<0.05; * p<0.1)


poisson total_diffusion GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data IPR Year, vce(robust)
margins, dydx(*) post
estimates store total_diffusion_poisson
outreg2 [total_diffusion_poisson] using  "XXXXX\Table_5.doc", append keep(GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data Year) addtext(Model, Poisson) ctitle(Total diffusion) nonotes addnote(Robust standard errors in parentheses., *** p<0.01; ** p<0.05; * p<0.1)


poisson countries_diffusion GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data IPR Year, vce(robust)
margins, dydx(*) post
estimates store countries_diffusion_poisson
outreg2 [countries_diffusion_poisson] using  "XXXXX\Table_5.doc", append keep(GDP ITA_trade Data_protection E_transaction Cybercrime Consumer_protection DTRI Polity No_of_members GDP_asymmetry Intercontinental USA_member Legalization Ecommerce Data Year) addtext(Model, Poisson) ctitle(External diffusion) nonotes addnote(Robust standard errors in parentheses., *** p<0.01; ** p<0.05; * p<0.1)


*** Replicate "Figure 1: Number of provisions first introduced by initiator countries"


clear
use online_appendix_elsig_klotz_2021_data
gen provision = 1
collapse(sum)provision, by(provision_first_power_alpha)
sort provision_first_power_alpha provision
gen sortvar = provision*-1
sort provision
set scheme s1mono
graph bar provision, over(provision_first_power_alpha, sort(sortvar) label(labsize(vsmall)angle(90))) ytitle("Number of provisions first introduced") b1title("Country")
graph export Figure_1.png, replace
graph export Figure_1.pdf, replace


*** Replicate "Figure 2: Digital trade-related provisions and their diffusion"


clear
use online_appendix_elsig_klotz_2021_data
gen sortvar = total_diffusion*-1
set scheme s1mono
graph hbar total_diffusion, over(provision_name, sort(sortvar) label(labsize(tiny))) ytitle("Number of PTAs")
graph display, ysize(10)
graph export Figure_2.png, replace
graph export Figure_2.pdf, replace


*** Replicate "Figure 3: Distribution of the dependent variable"


clear
use online_appendix_elsig_klotz_2021_data
set scheme s1mono
hist total_diffusion, freq xtitle("Total diffusion")
graph export Figure_3.png, replace
graph export Figure_3.pdf, replace